<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
  <link rel="stylesheet" title="Default" href="http://acm.math.spbu.ru/~sk1/colorer/my.css">

  <script src="http://acm.math.spbu.ru/~sk1/colorer/highlight.js"></script>
  <script src="http://acm.math.spbu.ru/~sk1/colorer/cpp.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
</head>

<body>

<pre><code>
/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com5
 * Date: 2013.10.18
 */

#include &lt;cstdio&gt;
#include &lt;cassert&gt;
#include &lt;algorithm&gt;
#include &lt;bitset&gt;
#include &lt;vector&gt;

using namespace std;

#define forn(i, n) for (int i = 0; i &lt; (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i &gt;= 0; i--)

typedef vector &lt;int&gt; vi;

const int N = 300;

int n, m;
vi v[N], x;

int subset( int i, int j )
{
  forn(k, n)
    if (v[i][k] && !v[j][k])
      return 0;
  return 1;
}

int main()
{
  while (scanf("%d%d", &n, &m) == 2 && (n || m))
  {
    forn(i, m)
    {
      int k, x;
      v[i] = vi(n, 0);
      scanf("%d", &k);
      while (k--)
        scanf("%d", &x), v[i][x - 1] = 1;
    }
    sort(v, v + m);

    int ans = 0;
    fornd(i, m)
    {
      vi x(n, 0);
      forn(j, i)
        if (subset(j, i))
          forn(k, n)
            x[k] |= v[j][k];
      int need = 0;
      forn(k, n)
        need |= !x[k] && v[i][k];
      ans += !need;
    }
    printf("%d\n", ans);
  }
  return 0;
}

</code></pre>

</body>
</html>

<font style="visibility:hidden">
